package com.jintoufs.dao.baseinfo.impl;

import com.jintoufs.dao.MyBatisSupport;
import com.jintoufs.dao.QueryFilters;
import com.jintoufs.dao.baseinfo.CustomerDAO;
import com.jintoufs.domain.baseinfo.Customer;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/9/1 0001.
 */
@Repository
public class CustomerDAOImpl extends MyBatisSupport<CustomerDAO, Customer> implements CustomerDAO {

    @SuppressWarnings("serial")
    private static Map<String, Object> fildMap = new HashMap<String, Object>() {
        {
            put("id", "c.id");
            put("name", "c.name");
            put("sex", "c.sex");
            put("mobilePhone", "c.mobile_phone");
            put("landLine", "c.landLine");
            put("email", "c.email");
        }
    };

    @Override
    public List<Customer> queryByParams(Map<String, Object> params) {
        return getMapper().queryByParams(params);
    }

    @Override
    public void insert(Customer customer) {
        getMapper().insert(customer);
    }

    @Override
    public void update(Customer customer) {
        getMapper().update(customer);
    }

    @Override
    public void delete(Integer id) {
        getMapper().delete(id);
    }

    @Override
    public List<Customer> getByFilter(QueryFilters filters) {
        filters.format(fildMap);
        return getMapper().getByFilter(filters);
    }

    @Override
    public Map<String, Object> getById(int id) {
        return getMapper().getById(id);
    }
}
